package com.zhai.application.md;

import com.alibaba.fastjson.JSONArray;

/**
 * @author zhaieryuan
 * @version 1.0.0
 * @description
 * @since 2022/6/27 14:02
 */
public class Demon02 {

    public static void main(String[] args) {


        String s = Demon02.stepOne(sitePoints, 1);
        System.out.println(s);

        int num = 32446;

        int step = num / 10;

        switch (step) {
            case 0:
                System.out.println("0");
                break;
            case 1:
                System.out.println("1");
                break;
            case 2:
                System.out.println("2");
                break;
            case 3:
                System.out.println("3");
                break;
            case 4:
                System.out.println("4");
                break;
            default:
                System.out.println("5");
        }

    }

    private static final String sitePoints = "[[116.787491,39.535369],[116.787743,39.535386],[116.788502,39.53546]," +
            "[116.788945,39.535508],[116.789687,39.535625],[116.789913,39.535655],[116.789913,39.535655]," +
            "[116.789717,39.536376],[116.78934,39.537743],[116.788993,39.538984],[116.78878,39.539792]," +
            "[116.788728,39.540009],[116.788663,39.540234],[116.788493,39.540842],[116.788333,39.541428]," +
            "[116.788198,39.541918],[116.787912,39.542973],[116.787842,39.543247],[116.787278,39.545308]," +
            "[116.7871,39.545972],[116.787074,39.546068],[116.786657,39.547578],[116.78648,39.548199]," +
            "[116.786375,39.548568],[116.786375,39.548568],[116.787504,39.54875],[116.791493,39.549375]," +
            "[116.791571,39.549384],[116.795789,39.550043],[116.799474,39.550612],[116.800512,39.550777]," +
            "[116.801145,39.550881],[116.801558,39.550968],[116.801948,39.551068],[116.804761,39.551949]," +
            "[116.806636,39.552539],[116.807339,39.552752],[116.808407,39.55309],[116.808515,39.553125]," +
            "[116.809405,39.553398],[116.809539,39.553442],[116.810438,39.55372],[116.810529,39.553746]," +
            "[116.813068,39.554536],[116.817078,39.555794],[116.82029,39.556797],[116.822777,39.557569]," +
            "[116.824631,39.558129],[116.826341,39.558641],[116.828611,39.559319],[116.83052,39.559905]," +
            "[116.83052,39.559905],[116.831367,39.558025],[116.831536,39.557747],[116.831718,39.557504]," +
            "[116.831957,39.557227],[116.833402,39.555655],[116.83523,39.553659],[116.835915,39.552899]," +
            "[116.835963,39.552843],[116.837855,39.550777],[116.837873,39.55076],[116.84085,39.547487]," +
            "[116.842677,39.545495],[116.842894,39.545239],[116.8448,39.54316],[116.84519,39.542717],[116.845494,39.542352]," +
            "[116.845846,39.541849],[116.846063,39.541532],[116.846271,39.541189],[116.846822,39.540152],[116.847005,39.539792]," +
            "[116.850581,39.532721],[116.852569,39.528806],[116.852747,39.528459],[116.85299,39.527964],[116.855164,39.523694]," +
            "[116.855577,39.522847],[116.85562,39.52276],[116.856124,39.521753],[116.857261,39.51947],[116.858107,39.517821]," +
            "[116.859665,39.514766],[116.861458,39.511228],[116.861714,39.510716],[116.861909,39.510304],[116.862022,39.510174]," +
            "[116.862022,39.510174],[116.868572,39.510208],[116.869279,39.510213],[116.872556,39.51023],[116.873485,39.510234]," +
            "[116.87414,39.51026],[116.874904,39.51033],[116.875134,39.510369],[116.875711,39.510469],[116.87654,39.510642]," +
            "[116.879578,39.511324],[116.880881,39.511619],[116.882452,39.511975],[116.883971,39.512318],[116.887786,39.51319]," +
            "[116.887838,39.513307],[116.887838,39.513307],[116.887721,39.514444],[116.887296,39.517661],[116.887269,39.517821]," +
            "[116.886775,39.52135],[116.886666,39.522122],[116.886397,39.524076],[116.886267,39.525104]]";

    /**
     * @param arrayJson
     * @param step
     * @return
     */
    public static String stepOne(String arrayJson, int step) {
        JSONArray array = JSONArray.parseArray(arrayJson);
        StringBuilder points = new StringBuilder();

        for (int i = 0; i < array.size(); i++) {
            if (i % step == 0) {
                Object o = array.get(i);
                String replace = o.toString().replace("[", "").replace("]", "").replace("\"", "");
                points.append(replace).append(";");
            }
        }
        return points.toString();
    }


}
